<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> - 基本表单</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="../favicon.ico">
    <link href="__PUBLIC__/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/animate.css" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/style.css?v=4.1.0" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>消息管理-
                        <small>系统消息</small>
                    </h5>
                    <div class="ibox-tools">
                        <a href="javascript:;" onclick="add_msg()" class="btn btn-info ">添加消息</a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form method="post" class="form-horizontal" onsubmit="return false">

                        <div class="form-group">
                            <label class="col-sm-2 control-label">*推送手机号</label>
                            <div class="col-sm-10">
                                <input type="text" name="title" id="mobiles"  placeholder="手机号，多个使用英文逗号','隔开" class="form-control"><br>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">快速选择内容</label>
                            <div class="col-sm-10">

                                <select name="content" id="content" style="width: 100%;height: 30px" onchange="msg_change()">
                                    <option value=""></option>
                                    <volist name="msg" id="vo">
                                        <option value="<{$vo.id}>"><{$vo.content}></option>
                                    </volist>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*发送内容</label>
                            <div class="col-sm-10">
                              <textarea placeholder="发送的主要内容" id="send_content"  style="width: 500px;height: 200px"  ></textarea>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="button" onclick="send()">发送</button>
                            </div>
                        </div>

                    </form>

                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="__PUBLIC__/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="__PUBLIC__/admin/js/bootstrap.min.js?v=3.3.6"></script>
<!-- 自定义js -->
<script src="__PUBLIC__/admin/js/content.js?v=1.0.0"></script>
<script src="__PUBLIC__/admin/js/plugins/layer/layer.min.js"></script>
<script>

    //消息赋值
    function msg_change() {
      var content=  $("#content").find("option:selected").text();
      $('#send_content').val(content);
    }


    //添加消息
    function add_msg() {
        layer.open({
            title:'添加推送消息',
            type: 2,
            area: ['40%', '50%'],
            maxmin: true,
            offset:'100px',
            content: '__MODULE__/Message/add_msg',
            success: function(layero){
                layero.find('.layui-layer-min').remove();
            }
        });
    }

    var shop_identifier="<{$shop_identifier}>";

    function send() {
        var index = layer.load(1, {
            shade: [0.1, '#fff'] //0.1透明度的白色背景
        });
        var url = "__MODULE__/Message/sys_msg";

        var mobiles = $("#mobiles").val();
//     = $("#content").text();
//        var content =  $("#content").find("option:selected").text();
        var content= $('#send_content').val();
        if (mobiles == ""  || mobiles == null || content == ""  || content == null) {
            layer.close(index);
            layer.alert("请信息填写完整！\r\n", {
                title: '提示框',
                icon: 0,
            });
            return false;
        }

        $.post(url, {mobiles:mobiles,content:content}, function (data) {
            console.log('343434',data);
            if (data.code == "1001") {
                layer.alert(data.result, {title: '提示框', icon: 1}, function (index) {

                    window.location.reload();
                });
            }
            else {
                layer.alert(data.result, {title: '提示框', icon: 2});
                layer.close(index);
            }
        });
        layer.close(index);
    }
</script>

</body>
</html>
